package com.huaxin.device.feignClients.impl;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.huaxin.device.feignClients.InspectionFeignService;
import com.huaxin.feignclient.models.ResponseCode;
import com.huaxin.feignclient.workOrder.InspectionClient;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
@RequiredArgsConstructor
public class InspectionFeignServiceImpl implements InspectionFeignService {
    private final InspectionClient inspectionClient;
    private final ObjectMapper objectMapper;

    @Override
    public Boolean existsByCabinetType(String cabinetType) {
        com.huaxin.feignclient.models.ResponseResult<Boolean> result = inspectionClient.existsByCabinetType(cabinetType);
        if (result.getCode() != ResponseCode.SUCCESS.getCode() || result.getData() == null) {
            return null;
        }
        return result.getData();
    }

    @Override
    public List<Map<String, Object>> countItemsByRoomIds(List<String> roomIds, String inspectionOrderId) {
        if (roomIds == null || roomIds.isEmpty()) {
            return null;
        }
        com.huaxin.feignclient.models.ResponseResult<List<Map<String, Object>>> result = inspectionClient.countItemsByRoomIds(roomIds, inspectionOrderId);
        if (result.getCode() != ResponseCode.SUCCESS.getCode() || result.getData() == null) {
            return null;
        }
        return result.getData();
    }
}
